package com.anjubao.parking.municipal.payment.constant;

import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * 支付渠道
 * @author zhuchunfeng
 * @date 2019/4/24 11:10
 */
@Getter
@AllArgsConstructor
public enum PayChannelIdEnum{

    //1：微信支付 2:支付宝支付 3:银联支付 4:余额支付 5:余额支付 99:其他
    WX_PAY(1, "微信支付"),
    ALI_PAY(2, "支付宝支付"),
    UNION_APY(3, "银联支付"),
    CASH(4, "余额支付"),
    BALANCE(5,"现金支付"),
    OTHER(99, "其他");

    private Integer code;

    private String desc;

    public static String getDescByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (PayChannelIdEnum e : PayChannelIdEnum.values()) {
            if (e.getCode() == code) {
                return e.getDesc();
            }
        }
        return null;
    }

    public static Boolean exist(Integer code) {
        if (code == null) {
            return false;
        }
        for (PayChannelIdEnum e : PayChannelIdEnum.values()) {
            if (e.getCode() == code) {
                return true;
            }
        }
        return false;
    }
}
